package com.itheima.demo;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

/**
 * @author brianxia
 * @version 1.0
 * @date 2021/8/8 10:32
 */
@Component
public class HealthIndicate implements HealthIndicator {
    public volatile boolean test = false;
    @Override
    public Health getHealth(boolean includeDetails) {
        //up down
        test = !test; //true -> false
        return test? Health.up().build() : Health.down().withDetail("why","手写健康检查").build();
    }

    @Override
    public Health health() {
        //up down
        test = !test; //true -> false
        return test? Health.up().build() : Health.down().withDetail("why","手写健康检查").build();
    }
}
